package com.myproject.myspringboot.pojo;

import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

/**
 * @User: hsh
 * @Date: 2019/11/19 10:50
 * @Description: 测试@configurationproperties和@PropertySource以及@Value的用法；
 */
@Data
@Configuration //注意把实体放到容器中，防止获取配置值失效；
@ConfigurationProperties(prefix = "person2")//获取主配置文件中对应实体的属性绑定；
@PropertySource(value = "classpath:config/${spring.profiles.active}/config.properties",encoding = "utf-8")
public class MyPerson {

    //@Value("${person2.name}")
    private String name;
    //@Value("${person2.age}")
    private Integer age;
    //@Value("${person2.sex}")
    private String sex;
    private Dog dog;
}
